//
//  ViewController.swift
//  表情键盘
//
//  Created by SteveLi on 2017/10/24.
//  Copyright © 2017年 李军桦. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    lazy var emotionView: EmotionView = EmotionView { [weak self]
        (emotion)-> () in
        self?.insertEmoticon(em: emotion)
    }
    ///表情键盘视图
    
    //表情模型
    func insertEmoticon(em:Emoticon){
        textView.text = em.chs
    }
    
    @IBOutlet weak var textView: UITextView!
    
    deinit {
        print("88")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        textView.inputView = emotionView
        textView.becomeFirstResponder()

    }
    
    func demo() {
        //输入视图
        //textView.inputView = UIButton(type: .contactAdd)
        let v = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 258))
        v.backgroundColor = UIColor.red
        //textView 会对 v 强引用
        textView.inputView = v
        textView.inputAccessoryView = UIButton(type: .contactAdd)

    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }
}

